package Q2;

import java.util.Scanner;

public class Main {

    public static int n;
    public static int[] arr;
    public static long ret;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        n = scanner.nextInt();
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        dfs(0, 0);

        System.out.println(ret);
    }

    public static void dfs(int index, long sum) {
        if (index >= n) {
            ret = Math.max(ret, sum);

            return;
        }

        //选
        if (index >= 1 && index < n - 1) {
            int left = arr[index - 1];
            int mid = arr[index];
            int right = arr[index + 1];
            arr[index - 1] = 0;
            arr[index] = 0;
            arr[index + 1] = 0;
            dfs(index + 3, sum + mid);
            //回溯
            arr[index - 1] = left;
            arr[index] = mid;
            arr[index + 1] = right;
        }

        //不选
        dfs(index + 1, sum);
    }
}
